var form = layui.form,table = layui.table, $ = layui.jquery,id = getQueryVariable("id"),ids="";
//表单初始值
if (id != "") {
    form.val("editor-form", {
        "receiptnumber": "单据编号",
    })
}
$('#editor-form').find('input,textarea,select').attr('disabled',true);

let detailData = [];
layer.ready(function () {
    //获取详情信息
    $.ajax({
        type:"POST",
        dataType:"json",
        contentType: 'application/json',
        data:JSON.stringify(id),
        url:"resourceSamples/detail",
        success:function(res){
            if(res.status == 200){
                //主表信息赋值
                $("#billNo").val(res.data.billNo);
                $("#createDate").val(res.data.createDate);
                $("#operator").val(res.data.operator);
                $("#customerName").val(res.data.customerName);
                $("#warehouseName").val(res.data.warehouseName);
                $("#typeStr").val(res.data.typeStr);
                $("#memo").val(res.data.memo);

                //产品列表信息
                detailData = res.data.detailList;

                table.reload('productinformationtableid',{data : detailData});

                return false;
            }else {
                layer.msg(res.msg, {icon: 5});
            }
        }
    });
})

table.render({
    elem: '#productinformation',
    id: 'productinformationtableid',
    data: detailData,
    toolbar: '#productinformationtoolbar',
    cols: [[
        {field: 'img', title: '产品图片', width: 120, align: 'center', templet: '#imgTpl'},
        {field: 'productCode', width: 120, title: '产品编码'},
        {field: 'specificationCode', width: 120, title: '规格编码',sort: true},
        {field: 'productCname', width: 120, title: '中文名称',sort: true},
        {field: 'productEname', width: 120, title: '英文名称',sort: true},
        {field: 'productCdesc', width: 120, title: '中文描述',sort: true},
        {field: 'productEdesc', width: 120, title: '英文描述',sort: true},
        {field: 'unitPrice', width: 120, title: '单价',sort: true},
        {field: 'productNum', width: 120, title: '数量',sort: true},
        {field: 'productUnit', width: 120, title: '单位'},
        {field: 'articleNo', width: 120, title: '货位',sort: true},
        {field: 'supplierName', title: '供应商', width: 240},
        {field: 'lotNo', width: 180, title: '批次号',sort: true},
        {field: 'warehouseName', width: 160, title: '资源样品仓库'},
        {field: 'specificationExplanation', width: 120, title: '备注',sort: true},
    ]],
    page: true,
    height: 380
    , done: function (res, curr, count) {
        hoverOpenImg();//显示大图
    }
});
function hoverOpenImg() {
    var img_show = null; // tips提示
    $("body").delegate("td img", "mouseover", function () {
        var img = "<img class='img_msg' src='" + $(this).attr('src') + "' style='width:130px;' />";
        img_show = layer.tips(img, this, {
            tips: [2, 'rgba(41,41,41,.5)']
            , area: ['160px']
        });
    });
    $("body").delegate("td img", "mouseout", function () {
        layer.close(img_show);
    });
}